home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 376-400 / disk_376 / toollibrary / toollibrary.doc.engl < prev    next >
Text File  |  1992-05-06  |  10KB  |  317 lines

  1.  ToolLibrary V 2.06
  2.  © by Rüdiger Dreier 1988/9/90
  3.  Plotter is FREEWARE.
  4.  
  5.  
  6.  THE AUTHOR UNDERTAKES NO LIABILITY FOR ANY DAMAGE CAUSED BY THE APPROPRIATE
  7.  OR NOT APPROPRIATE USE OF THIS PROGRAM !
  8.  THE AUTHOR UNDERTAKES NO LIABILITY FOR THE FAULTLESSNESS OF THIS PROGRAM !
  9.  USE IT AT YOUR OWN RISK !
  10.  
  11.  The tool.library is a shared library  for the Amiga. Copy it to your LIBS:.
  12.  You  also  need mathieeedoubbas.library  and  mathieeedoubtrans.library  in
  13.  LIBS:.
  14.  
  15.  Open the library:
  16.              struct ToolBase *ToolBase; /* Global */
  17.  
  18.              ToolBase=(struct ToolBase *)OpenLibrary("tool.library,0");
  19.  
  20.  Struct ToolBase  contains pointers  to the  four libraries  IntuitionBase,
  21.  GfxBase   and  the  two   MathIeee.....Base's.  So,  if   a  program  uses
  22.  tool.library, you can get access to these other libraries like this:
  23.              IntuitionBase=ToolBase->IntuitionBase;
  24.  You  need not to  open them. Perhaps  that is not  legal, but tool.library
  25.  opens this libraries, so they are in memory. It works and should work with
  26.  newer versions of Kickstart, too.
  27.  
  28.  A short description of the functions:
  29.  
  30.  STRINGS:
  31.  VOID left (char *Dest,char *Source,LONG Number)(a0,a1,d0)
  32.  VOID right(char *Dest,char *Source,LONG Number)(a0,a1,d0)
  33.  VOID mid  (char *Dest,char *Source,LONG Start,LONG Number)(a0,a1,d0,d1)
  34.  
  35.  These three  functions are  similar to  those in  Basic. Dest  must be  big
  36.  enough.
  37.  
  38.  VOID copy(LONG start,LONG Number,char *Dest,char *source)(d0,d1,d2,d3)
  39.  
  40.  This function is similar to mid, it is here cause of compatibility.
  41.  
  42.  
  43.  LONGcheck (LONG Char1,LONG Char2,LONG Start,LONG End,char *String)
  44.            (d0,d1,d2,d3,a0)
  45.  LONG checkback(LONG Char1, LONG Char2, LONG Start, LONG End, char *String)
  46.                (d0,d1,d2,d3,a0)
  47.  
  48.  This  two functions  are quite  difficult to  explain. They  search for the
  49.  first  appearance of the two  chars (Char1 and Char2).  Therefore, they are
  50.  aware of the brackets. Checkback begins  at the end of the string, check at
  51.  the beginning. Example:
  52.  string:            1+(2-4)    Start:0    End:6
  53.  The - sign is not found, because of the brackets.
  54.  string:            1+(2-4)    Start:3    End:5
  55.  The - sign is found, a 4 is returned.
  56.  
  57.  
  58.  LONG AnzahlKlammern(char *String)(a0)
  59.  
  60.  (Numberofbrackets) Returns the number of open brackets:
  61.  Returns:          0: there is exactly one ( for every )
  62.              <0: too much )
  63.              >0: too much (
  64.  
  65.  
  66.  HELP FOR INTUITION AND GRAPHIC
  67.  
  68.  LONG request(char *yes,char *no,char *body)(d0,d1,d2)
  69.  
  70.  Opens an autorequester on the actual screen. 
  71.  
  72.  LONG NewRequest(    struct Window *Window,
  73.                  char *yes,
  74.                  char *no,
  75.                  char *body)(a0,d0,d1,d2)
  76.  The same as before, but here you can decide for which window the requester
  77.  appears.
  78.  
  79.  
  80.  LONG EventAbfrage(struct Window *Window,struct info *msginfo)(a0,a1)
  81.  
  82.  You can use this function instead of GetMsg();ReplyMsg();
  83.  
  84.  
  85.  VOID Print(struct RastPort *RP,
  86.             char *text,
  87.             LONG col,
  88.             LONG xpos,
  89.             LONG ypos)(a1,a0,d0,d1,d2)
  90.  
  91.  Displays a text on the RastPort.
  92.  
  93.  
  94.  VOID Center(struct Window *Window,
  95.              char *text,
  96.              LONG Farbe,
  97.              LONG yPos)(a1,a0,d0,d1)
  98.  
  99.  The same, but here the text is automatically centered.
  100.  
  101.  
  102.  VOID Box(struct RastPort *RP,
  103.           LONG x1,y1,x2,y2)(a1,d0,d1,d2,d3)
  104.  
  105.  Draws a box on the RastPort.
  106.  
  107.  
  108.  VOID Gadget_On (struct Gadget *Gadget,struct Window *Window)(a0,a1)
  109.  VOID Gadget_Off(struct Gadget *Gadget,struct Window *Window)(a0,a1)
  110.  
  111.  These two  functions can be used instead  of GadgetOn/Off (from Intuition.
  112.  library). Gadget_On makes sure that the Gadget is not only active but also
  113.  correctly drawn.
  114.  
  115.  
  116.  LONG GetPropPosH(struct Gadget *Gadget,LONG MaxPos)(a0,d0)
  117.  LONG GetPropPosV(struct Gadget *Gadget,LONG MaxPos)(a0,d0)
  118.  VOID SetPropPosH(    struct Gadget *Gadget,
  119.                  struct Window *Window,
  120.                       LONG MaxPos,
  121.                  LONG Step,
  122.                  LONG NewPos)(a0,a1,d0,d1,d2)
  123.  VOID SetPropPosV(    struct Gadget *Gadget,
  124.                  struct Window *Window,
  125.                  LONG MaxPos,
  126.                  LONG Step,
  127.                  LONG NewPos)(a0,a1,d0,d1,d2)
  128.  
  129.  These four functions are for easier use of the propgadgets.
  130.  MaxPos: maximum number of positions for this gadget
  131.  Step  : number of positions, the knob moves when clicking in the gadget
  132.  NewPos: the new position.
  133.  
  134.  
  135.  LONG PrepareTmpRas(struct RastPort *RP)(a1)
  136.  VOID ClearTmpRas  (struct RastPort *RP)(a1)
  137.  
  138.  To   prepare  a   RastPort  for  the   use  of   the  Flood-function,  use
  139.  PrepareTmpRas. It returns 0 when there was not enough memory or the TmpRas
  140.  was  already installed. Before  exit, you should call  ClearTmpRas to free
  141.  memory.
  142.  
  143.  
  144.  LONG PrepareArea(struct RastPort *RP,LONG MaxPoints)(a1,d0)
  145.  VOID ClearArea  (struct RastPort *RP)(a1)
  146.  
  147.  The Area-functions  need a bit more  of work. So if you  want to use them,
  148.  call PrepareArea.  Do NOT call PrepareTmpRas first !  This call is part of
  149.  PrepareArea. It returns 0 if it failed. To free memory, call ClearArea.
  150.  
  151.  
  152.  To get simple menus very fast, use the following functions:
  153.  DO NOT USE ANY STATIC MENUS !
  154.  struct Menu *AddMenu(struct Menu *menu,
  155.                       char *Title,
  156.                       unsigned short Flags);
  157.  
  158.  This function  adds a menu to  the list. For the first  call, menu must be
  159.  ZERO ! The  return value of the first call is  the "menu" argument for all
  160.  other calls  to  any of  the  Add..functions  ! So  you  have to  save  it
  161.  somewhere. You do not need the return value of the other calls.
  162.  
  163.  struct Item *AddItem(struct Menu *menu,
  164.                       char *Title,
  165.                       unsigned short Flags,
  166.                       char HotKey);
  167.  
  168.  This  function adds an item  to the last menu  in the list. If  Title is a
  169.  pointer to  char, INTUITEXT  must be  set in  Flags. Otherwise,  Title  is
  170.  interpreted as pointer to a Image-struct and an image is displayed. If you
  171.  want to  use a HotKey, also  COMMSEQ must be set in  Flags. The memory for
  172.  the item (and if needed) the intuitext is allocated. BackPen, FrontPen and
  173.  DrawMode are set by using the values from the first item of the first menu
  174.  (if  there is one).  Otherwise some  standart values are  taken. To change
  175.  e.g. the BackPen, use the following:
  176.  struct Item *item;
  177.  struct IntuiText *IT;
  178.  item=AddItem(menu,"TestItem",INTUITEXT,0);
  179.  IT=(struct IntuiText *)item->ItemFill;
  180.  IT->BackPen=....;
  181.  If this item is the first item  of the first menu, this value will be used
  182.  for all items and subitems.
  183.  THERE  IS NO MEMORY  ALLOCATED FOR THE  STRING, FREEING THE  MEMORY OF THE
  184.  STRING MAY CAUSE A GURU !
  185.  
  186.  
  187.  struct Item *AddSub(struct Menu *menu,
  188.                      char *Title,
  189.                      unsigned short Flags,
  190.                      char HotKey);
  191.  
  192.  Add a subitem to the last defined item.
  193.  
  194.  
  195.  VOID NewSetMenuStrip(struct Window *Window,struct Menu *menu);
  196.  
  197.  To make the menu active, use this command instead of SetMenuStrip();
  198.  
  199.  
  200.  VOID ClearMenu(struct Menu *menu);
  201.  
  202.  To  free  the memory  of  the  menu,  use  this function.  You  MUST  call
  203.  ClearMenuStrip(); first !!!!!
  204.  
  205.  
  206.  struct Menu *LastMenu(struct Menu *menu);
  207.  struct MenuItem *LastItem(struct Menu *menu);
  208.  struct MenuItem *LastSub(struct Menu *menu);
  209.  struct Menu *FreeMenu(struct Menu *menu);
  210.  struct MenuItem *FreeItem(struct MenuItem *item);
  211.  
  212.  These functions are used by the other function. If you need them.......
  213.  
  214.  
  215.  MATHEMATICAL FUNCTIONS
  216.  
  217.  VOID UmwFtoS(char *Dest,DOUBLE *Number,LONG Nachkomma)(a0,a1,d0)
  218.  
  219.  Converts a DOUBLE to a string. Example:
  220.  DOUBLE a=5.34524352;
  221.  char string[50];
  222.  UmwFtoS(string,&a,3); -> string: 5.345
  223.  UmwFtoS(string,&a,5); -> string: 5.34524
  224.  
  225.  
  226.  VOID UmwStoF(DOUBLE *Dest,char *Source)(a0,a1)
  227.  
  228.  And vice versa.......
  229.  
  230.  
  231.  VOID Fak(DOUBLE *Dest,LONG a)(a0,d0)
  232.  VOID NuK(DOUBLE *Dest,LONG a,LONG b)(a0,d0,d1)
  233.  
  234.  Fak calculates a!, NuK calculates a!/(b!*(b-a)!)
  235.  
  236.  
  237.  APTR Init_Konst()()
  238.  
  239.  Allocates memory for 26 DOUBLEs.
  240.  
  241.  
  242.  LONG Set_Konst_P(APTR Zeiger,LONG Nummer,DOUBLE *Wert)(a0,d0,d1)
  243.  
  244.  You can set one of these 26 DOUBLE to Wert.
  245.  
  246.  VOID GetKonst_P(DOUBLE *Dest,APTR Zeiger,LONG Nummer)(a0,a1,d1)
  247.  
  248.  And read them again...
  249.  
  250.  VOID Free_Konst(APTR Zeiger)(a0)
  251.  
  252.  To free the memory....
  253.  
  254.  
  255.  struct Block *Init_Mem(char *Zeiger)(a0)
  256.  LONG Init_Block(struct Block *Zeiger)(a0)
  257.  LONG PreCalc(struct Block *Zeiger,APTR Konstanten)(d0,d1)
  258.  LONG Calc_P(DOUBLE *Dest,struct Block *Zeiger,DOUBLE *Wert)(a0,a1,a2)
  259.  VOID Free_Block(struct Block *Zeiger)(a0)
  260.  
  261.  Difficult.  Let's say you have  a string STRING="sin(x)". Now  you want to
  262.  know the "value" of the string for x=3. So:
  263.  Call Init_Mem:        Start=Init_Mem(STRING);
  264.  Start should be a pointer to Block.
  265.  Then:                Init_Block(Start);
  266.  After  this, STRING is no  longer used. Init_Mem allocates  the memory for
  267.  the first  "Block"  and  Init_Block calculates  a  tree according  to  the
  268.  function in STRING.
  269.  Then:                PreCalc(Start,Const);
  270.  Const should be the pointer you get from Init_Konst() or NULL; 
  271.  To get the value of sin(x) for x=3 :
  272.                      DOUBLE x=3.0,Dest;
  273.                      Calc_P(&Dest,Start,&x);
  274.  Now  you have  the value in  Dest. If  you now want  to know  the same for
  275.  x=3.1:                x=3.1;
  276.                      Calc_P(&Dest,Start,&x);
  277.  Easy, isn't it ?
  278.  To free the memory, call Free_Block(Start);
  279.  Three of  these functions  return  a LONG,  it  is an  error code.  It  is
  280.  explained in tool.h.
  281.  
  282.  The  string may  consist of: +-*/^,  e(2.7..), pi(3.14..),  a-z (exept e),
  283.  ((a)sin, (a)cos, (a)tan), log, ln,  abs (Absolut), sgn (sign), int and sqr
  284.  and numbers (1; 1.0; .1;1e5;-3d-5). All characters must be lower case ! 
  285.  Constants must be set with the _Konst functions. If you change a constant,
  286.  you must call PreCalc again.
  287.  
  288.  
  289.  VOID berechnen(DOUBLE *Dest,char *string,
  290.                 DOUBLE *x,
  291.                 struct Konstanten *konstanten,
  292.                 LONG *fehler)(a0,d0,d1,d2,d3)
  293.  
  294.  If you only  want to calculate one value, use  this function: It needs the
  295.  same  parameters and does  everything that is  needed. But if  you want to
  296.  calculate more values for the same function, the long way is faster.
  297.  
  298.  
  299.  If  you  have  hints,  questions (please  add  postage  for  the  answer),
  300.  bug-reports or money for me, here is my address:
  301.  
  302.          Rüdiger Dreier
  303.          Gustav-Winkler Str. 40
  304.         D-4800 Bielefeld 18
  305.          West Germany
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.   
  315.   
  316.   
  317.